package com.hxkj.cst.chengshuitong.ui.fragment

import android.support.v7.widget.LinearLayoutManager
import android.util.SparseArray
import android.view.View
import com.hxkj.cst.chengshuitong.R
import com.hxkj.cst.chengshuitong.RatePaymentEnum
import com.hxkj.cst.chengshuitong.base.RatePaymentFragment
import com.hxkj.cst.chengshuitong.ui.adapter.RatePaymentTableAdapter
import com.hxkj.cst.chengshuitong.util.LogUtils
import kotlinx.android.synthetic.main.fragment_second_payment.view.*

/**
 * 作者：LuoYang
 * 时间：2017/5/31:15:40
 * 邮箱：18981443691@163.com
 * 说明：
 */
class RatePaymentSecondFragment : RatePaymentFragment() {
    override fun provideContentView(): Int = R.layout.fragment_second_payment

    override fun initLayout(view: View) {
        setUpRecyclerView(view)
        view.fsecond_btn_next.setOnClickListener {
            notifyObserver(RatePaymentEnum.THIRD_RATE_PAYMENT)
        }
    }

    fun setUpRecyclerView(view: View) {
        val layoutManager = LinearLayoutManager(activity)
        layoutManager.orientation = LinearLayoutManager.VERTICAL
        view.fsecond_rv_contain.layoutManager = layoutManager

        val typeArray = activity.resources.obtainTypedArray(R.array.RatePayment_Second_Describe)
        val sparseArray = SparseArray<String>()
        for (index in 0..typeArray.length() - 1) {
            sparseArray.put(index, "测试数据${typeArray.getString(index)}")
        }
        typeArray.recycle()
        LogUtils.e(sparseArray.size().toString())

        view.fsecond_rv_contain.adapter =
                RatePaymentTableAdapter(activity, sparseArray, R.array.RatePayment_Second_Describe)
    }
}